package org.shushan.web.demo.entity;

import lombok.Getter;
import lombok.Setter;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import org.shushan.framework.core.entity.IdEn;
import org.shushan.framework.core.mapstruct.EnMapstruct;
import org.shushan.web.demo.response.MongoTestVo;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.FieldType;
import org.springframework.data.mongodb.core.mapping.Sharded;

import java.io.Serializable;

/**
 * (TUser)实体
 * @author zhigang.li
 * @email 2429967859@qq.com
 * @since 2023-09-16 22:25:41
 */
@Getter
@Setter
@Sharded(value = "id")
@Document(value = "mongo_test")
public class MongoTest implements IdEn<Long>, EnMapstruct<MongoTestVo>, Serializable {
    private static final long serialVersionUID = -28434004787627803L;
    @Id
    private Long id;
    @Field(value = "trace_id",targetType = FieldType.STRING)
    private String traceId;
    @Field(value = "log_context",targetType = FieldType.STRING)
    private String logContext;
    @Field(value = "log_remark", targetType = FieldType.STRING)
    private String logRemark;

    @Override
    public MongoTestVo toVo() {
        return MongoTestMapper.INSTANCE.toVo(this);
    }

    @Mapper
    interface MongoTestMapper {
        MongoTestMapper INSTANCE = Mappers.getMapper(MongoTestMapper.class);

        MongoTestVo toVo(MongoTest tUser);
    }

}

